1. Field of the Invention
The present invention relates to a memory management method and a controller thereof. More particularly, the present invention relates to a memory management method for a non-volatile memory and a controller using the same.
2. Description of Related Art
With a quick developing of digital camera, cell phone camera and MP3, demand of storage media by customers is increased greatly. Since a flash memory has the advantages of non-volatile, energy saving, small size and none mechanical structure etc., it is suitable for portable applications, and especially for portable electronic products. Besides a demand of built-in memories of the portable electronic products, demand of the flash memories used for external products such as small memory cards and flash drives is increased greatly in the market since a user may simultaneously own a plurality of the small memory cards and the flash drives. Therefore, the flash drive industry becomes a hot industry within the electronics industry recently.
Though the flash drive has the advantages of programmable, erasable, data saving after power-off, erase times of blocks within the flash memory are limited. For example, the blocks in the flash memory may be worn after being erased 10,000 times. Data loss may be caused when the storage capacity or performance of a flash memory is obviously deteriorated by its worn-out blocks.
Wear of the flash memory blocks is determined by the number of times this block is programmed or erased. In other words, the wear of a block is relatively low if the block is programmed (or written) only once; contrarily, the wear of a block is relatively higher if the block is programmed and erased repeatedly. For example, when a host keeps writing data into a flash memory by using the same logical block address (LBA), the block having the corresponding physical block address (PBA) in the flash memory is then repeatedly written and erased.
Generally speaking, the existence of worn-out blocks will reduce the performance of a flash memory even if the wear of other blocks are still relatively low. Besides the deterioration in the performance of the worn-out blocks, the performance of the entire flash memory is also reduced when the good blocks cannot provide enough space for storing data. In other words, when the number of worn-out blocks in a flash memory exceeds a threshold value, the flash memory is considered unusable even there are still good blocks. In this case, those good blocks are wasted.
To prolong a lifespan of the flash memory, utilization of the blocks of the flash memory should be levelled. Generally, the blocks of the flash memory are grouped into a data area and a spare area. According to a conventional wear leveling method, when the flash memory is operated for a period of time, the blocks within the data area and the blocks within the spare area are logically exchanged sequentially, hopefully the blocks with lesser erase times may be exchanged to the data area for being programmed (or written).
When a wear leveling procedure is executed, the data block is selected according to the erase times of the block, so as to exchange data. However, an influence caused by block reading is not considered based on such selecting method. As cost of the flash memory decreases, performance and stability of a flash memory chip are influenced, so that not only the lifespan of the flash memory is limited by writing times thereof, excessive reading times thereof may also cause a read disturb problem, and data left unused for too long time may cause a data retention problem. Such problems become more serious as the stability of the flash memory decreases.
Accordingly, a memory management method is required to effectively prolong the lifespan of the flash memory.